<?php
		if(!isset($_GET['selection'])){

			$reqNews = "SELECT * FROM news";
			$queryListeNews = $bdd->query($reqNews);
			
			echo '<table>';
			
			while($news = $queryListeNews->fetch()){
				echo '
					
					<tr>
						<td>
							'.$news['titreNews'].'
						</td>
						<td>
							<form action = "index.php" method = "get">
							<input type = "hidden" name = "page" value = "admin" />
							<input type = "hidden" name = "action" value = "gererNews" />
							<input type = "hidden" name = "selection" value = "modifierNews" />
							<input type = "hidden" name = "idNews" value = '.$news['idNews'].' />
							<input type = "submit" value = "Modifier" />
							</form>
						</td>
						<td>
							<form action = "ctrl_administration.php" method = "post">
							<input type = "hidden" name = "do" value = "supprimerNews" />
							<input type = "hidden" name = "idNews" value = '.$news['idNews'].' />
							<input type = "submit" value = "Supprimer" />
							</form>
						</td>
					</tr>';
			}
			echo '</table>';
			$queryListeNews->closeCursor();
		}
		else if($_GET['selection'] = "modifierNews"){

			$reqNews = 'SELECT * FROM news WHERE idNews = '.$_GET['idNews'].'';
			$queryListeNews = $bdd->query($reqNews);
			while($news = $queryListeNews->fetch()){
				
				echo'
					<form action = "ctrl_administration.php" method = "post">
						<table>
							<tr>
								<td>
									<input type = "hidden" name = "do" value = "modifierNews" />
									<input type = "hidden" name = "idNews" value = "'.$_GET['idNews'].'" />
									<input type = "text" name = "titre" value = "'.$news['titreNews'].'" />
								</td>
							</tr>
							<tr>
								<td>
									<textarea name="contenuNews" rows="10" cols="40">'.$news['contenuNews'].'</textarea>
								</td>
							</tr>
							<tr>
								<td>
									<input type = "submit" value = "Modifier" />
								</td>
							</tr>
						</table>
					</form>
				';
				
			}
			$queryListeNews->closeCursor();
		
		}